#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int time;
    int level;
} Machine;

typedef struct {
    int time;
    int level;
} Task;

int compare_machine(const void* a, const void* b) {
    Machine* m1 = (Machine*)a;
    Machine* m2 = (Machine*)b;
    if (m1->time == m2->time) {
        return m2->level - m1->level;
    }
    return m2->time - m1->time;
}

int compare_task(const void* a, const void* b) {
    Task* t1 = (Task*)a;
    Task* t2 = (Task*)b;
    if (t1->time == t2->time) {
        return t2->level - t1->level;
    }
    return t2->time - t1->time;
}

int main() {
    int N, M;
    while (scanf("%d %d", &N, &M) != EOF) {
        Machine* machines = (Machine*)malloc(N * sizeof(Machine));
        Task* tasks = (Task*)malloc(M * sizeof(Task));

        for (int i = 0; i < N; i++) {
            scanf("%d %d", &machines[i].time, &machines[i].level);
        }

        for (int i = 0; i < M; i++) {
            scanf("%d %d", &tasks[i].time, &tasks[i].level);
        }

        // Sort machines and tasks
        qsort(machines, N, sizeof(Machine), compare_machine);
        qsort(tasks, M, sizeof(Task), compare_task);

        int completed_tasks = 0;
        long long total_income = 0;
        int* machine_used = (int*)calloc(N, sizeof(int));

        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                if (!machine_used[j] && machines[j].time >= tasks[i].time && machines[j].level >= tasks[i].level) {
                    machine_used[j] = 1;
                    completed_tasks++;
                    total_income += 500 * tasks[i].time + 2 * tasks[i].level;
                    break;
                }
            }
        }

        printf("%d %lld\n", completed_tasks, total_income);

        free(machines);
        free(tasks);
        free(machine_used);
    }

    return 0;
}